package com.ivan.blog.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @Author Ivan
 * @Description WebMvcConfig
 * @Date 2021/10/11 23:15
 */
@Configuration
public class WebMvcConfig extends WebMvcConfigurationSupport {

    //文件根路径
    @Value("${file.path}")
    private String fileRootPath;

    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/img/**").addResourceLocations("file:" + fileRootPath);
        registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
    }
}
